home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cenvid9.zip / KEYSTUFF.BAT < prev    next >
DOS Batch File  |  1994-03-04  |  2KB  |  68 lines

  1. @echo off
  2. REM ************************************************
  3. REM *** KeyStuff.bat - Stuff characters into the ***
  4. REM *** ver.1          keyboard buffer           ***
  5. REM ************************************************
  6.  
  7. SET THISFILE=%0
  8. SET KEYSTUFFS='
  9. :BUILD_KEYSTUFFS
  10. IF "%1" == "" GOTO END_BUILD
  11. IF "%KEYSTUFFS%" == "" SET KEYSTUFFS=%1
  12. IF NOT "%KEYSTUFFS%" == "" SET KEYSTUFFS=%KEYSTUFFS% %1
  13. SHIFT
  14. GOTO BUILD_KEYSTUFFS
  15. :END_BUILD
  16. SET KEYSTUFFS=%KEYSTUFFS%'
  17.  
  18. CEnvi %THISFILE%.bat %KEYSTUFFS%
  19. GOTO CENVI_EXIT
  20.  
  21. #define NEXT_CHAR_PTR      0x41A
  22. #define LAST_CHAR_PTR      0x41C
  23. #define KYBD_BUF_START_PTR 0x480
  24. #define KYBD_BUF_END_PTR   0x482
  25. #define DOS_STATIC_MEMORY  0x400
  26.  
  27. main(argc,argv)
  28. {
  29.    if ( !strcmpi(argv[1],"\'/?\'") ||  !strcmpi(argv[1],"\'\'") )
  30.       Instructions();
  31.    else {
  32.  
  33.       // get start and end address of the keyboard buffer
  34.       BufStart = peek(KYBD_BUF_START_PTR,UWORD16);
  35.       BufEnd = peek(KYBD_BUF_END_PTR,UWORD16) - 2;
  36.  
  37.       // Poke bytes from input arguments into the keyboard buffer
  38.       BufLen = min((BufEnd - BufStart)/2,1+GetArraySpan(KEYSTUFFS));
  39.       for ( Addr = BufStart, c = KEYSTUFFS; BufLen--; Addr += 2, c++ )
  40.          poke(Addr+DOS_STATIC_MEMORY,c[0]);
  41.  
  42.       // save pointers to beginning and ending of buffer
  43.       poke(NEXT_CHAR_PTR,BufStart,UWORD16);
  44.       poke(LAST_CHAR_PTR,Addr,UWORD16);
  45.  
  46.    }
  47. }
  48.  
  49. Instructions()
  50. {
  51.    printf("\a");
  52.    printf("KeyStuff - Push characters into the keyboard buffer\n");
  53.    printf("\n");
  54.    printf("USAGE: KeyStuff String\n");
  55.    printf("  Where String is fifteen or fewer bytes for the keyboard buffer\n");
  56.    printf("\n");
  57.    printf("EXAMPLE:  The following batch file would start up BASIC.COM with the initial\n");
  58.    printf("          command: Load \"Truck\"\n");
  59.    printf("                call KeyStuff Load\\x20\\\"Truck\\\"\\r\\n\n");
  60.    printf("                basica.com\n");
  61.    printf(" \n");
  62. }
  63.  
  64. :CENVI_EXIT
  65. SET THISFILE=
  66. SET KEYSTUFFS=
  67.  
  68.